﻿using System;
using CustomKeyGenerator.Model;
using Xtensive.Orm;
using Xtensive.Orm.Configuration;

namespace CustomKeyGenerator
{
    class Program
    {
        static void Main(string[] args)
        {
            // Loading domain configuration section with name "Default".
            var domainConfiguration = DomainConfiguration.Load("Default");
            var domain = Domain.Build(domainConfiguration);

            using (var session = domain.OpenSession()) {
                using (var t = session.OpenTransaction()) {

                    // See Person.cs for key generator configuration
                    // The key generator used produces sequential guids

                    Console.WriteLine(Key.Generate<Person>(session));
                    Console.WriteLine(Key.Generate<Person>(session));
                    Console.WriteLine(Key.Generate<Person>(session));
                    Console.WriteLine(Key.Generate<Person>(session));
                    Console.WriteLine(Key.Generate<Person>(session));
                    Console.WriteLine(Key.Generate<Person>(session));

                    t.Complete();
                }
            }
        }
    }
}
